Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for multi-queue synchronization. #114

Merged
merged 41 commits into from
Jan 5, 2024
Merged

Conversation

crud89
Copy link
Owner

@crud89 crud89 commented Jan 5, 2024

Describe the pull request

This PR adds an example that demonstrates how to use and synchronize workloads between multiple queues. The example performs a simple post-processing (RGB -> Luminance conversion) on a render target from an earlier render pass executed on another queue. Note that this is not the most efficient way to do this, as the sequential dependency between the render target and the post-processing step would typically not justify an possibly expensive queue switch, however it works well for demonstration purposes.

Alongside this example, many minor and major improvements have been implemented:

  • Input attachment mappings are now accessible through the IRenderPass interface (instead of requiring a downcast).
  • The current image layout can now be read-only accessed on IImage resources.
  • Cached command buffers are now released based on the fences that have passed on the command queue.
  • Render passes now return the fence signaling their end on the queue they have been submitted to for convenience.
  • Render targets are now created with a set of flags instead of boolean switches. There are even more usage flags now, that allow for sharing, write-access outside of the render pass and controlling the attachment behaviour in Vulkan.

Swap chains have received some significant changes as well:

  • Back buffer images can now be accessed for modification. This allows them to be used in scenarios like transfer destinations. In the example, the back buffers are populated by copying another buffer into them, instead of requiring a full render pass to render into them,
  • The native Vulkan swap chain now uses fences to synchronize frames in flight. The convoluted binary semaphores passed around through specialized interfaces have been removed.
  • The interop version of the Vulkan swap chain now supports proper async frames in flight. Previously, there was a full CPU-wait on the Vulkan semaphore before presenting. This has been replaced with shared semaphores that the D3D queue can wait on and a dedicated image resource that gets copied into the back buffer so that there are no synchronization issues. Note that there is a bug in the validation layers, that has been fixed in recent versions of the Vulkan SDK, which causes false positives on command buffer usage errors. Whilst the required SDK version is not raised, a warning will be printed when building against versions before 1.3.268.0.
  • All swap chains can now be presented after a certain fence value has been reached on the default graphics queue, instead of providing a frame buffer explicitly. This allows to issue presents outside of render passes. In the example, the compute shader modifies the render target of a render pass in post and then copies them into the swap chain back buffer before presenting it. The copy command buffer in this case signals the fence that allows for presentation to happen.

@crud89 crud89 added Priority: Medium A issue with normal priority. Requirement An implementation is required before the next release. Vulkan 🌋 The issue involves the Vulkan backend. DX12 ❎ The issue involves the DX12 backend. labels Jan 5, 2024
@crud89 crud89 added this to the Alpha #04 milestone Jan 5, 2024
@crud89 crud89 self-assigned this Jan 5, 2024
@crud89 crud89 marked this pull request as ready for review January 5, 2024 12:50
@crud89 crud89 merged commit d2380ee into main Jan 5, 2024
1 check failed
@crud89 crud89 deleted the compute-post-processing branch January 5, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX12 ❎ The issue involves the DX12 backend. Priority: Medium A issue with normal priority. Requirement An implementation is required before the next release. Vulkan 🌋 The issue involves the Vulkan backend.
Projects
Status: v0.4.1
Development

Successfully merging this pull request may close these issues.

1 participant